package com.corticon.client.model;

import java.io.Serializable;

public class QuestionBaseOutput implements Serializable, Comparable {
	public String sequence;
	public Integer questionPageId;
	public Integer questionId;
	public String text;
	public String uiControl;
	public String name;
	public String refId;
	public Integer version;
	public DataValidationOutPut dataValidation;

	public String dataType;
	public String responseType;
	public String helpText;
	public String[] answerValue;
	public String width;
	public String maxResponseValue;
	public String minResponseValue;
	public Integer maxResponses;
	public String rows;
	private Boolean reload;
	
	
	public Boolean getReload() {
		return reload;
	}
	public void setReload(Boolean reload) {
		this.reload = reload;
	}
	public String getSequence() {
		return sequence;
	}
	public void setSequence(String sequence) {
		this.sequence = sequence;
	}
	public Integer getQuestionPageId() {
		return questionPageId;
	}
	public void setQuestionPageId(Integer questionPageId) {
		this.questionPageId = questionPageId;
	}
	public Integer getQuestionId() {
		return questionId;
	}
	public void setQuestionId(Integer questionId) {
		this.questionId = questionId;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getUiControl() {
		return uiControl;
	}
	public void setUiControl(String uiControl) {
		this.uiControl = uiControl;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRefId() {
		return refId;
	}
	public void setRefId(String refId) {
		this.refId = refId;
	}
	public Integer getVersion() {
		return version;
	}
	public void setVersion(Integer version) {
		this.version = version;
	}
	public DataValidationOutPut getDataValidation() {
		return dataValidation;
	}
	public void setDataValidation(DataValidationOutPut dataValidation) {
		this.dataValidation = dataValidation;
	}
	public String getDataType() {
		return dataType;
	}
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}
	public String getResponseType() {
		return responseType;
	}
	public void setResponseType(String responseType) {
		this.responseType = responseType;
	}
	public String getHelpText() {
		return helpText;
	}
	public void setHelpText(String helpText) {
		this.helpText = helpText;
	}
	public String[] getAnswerValue() {
		return answerValue;
	}
	public void setAnswerValue(String[] answerValue) {
		this.answerValue = answerValue;
	}
	public String getWidth() {
		return width;
	}
	public void setWidth(String width) {
		this.width = width;
	}
	public String getMaxResponseValue() {
		return maxResponseValue;
	}
	public void setMaxResponseValue(String maxResponseValue) {
		this.maxResponseValue = maxResponseValue;
	}
	public String getMinResponseValue() {
		return minResponseValue;
	}
	public void setMinResponseValue(String minResponseValue) {
		this.minResponseValue = minResponseValue;
	}
	public Integer getMaxResponses() {
		return maxResponses;
	}
	public void setMaxResponses(Integer maxResponses) {
		this.maxResponses = maxResponses;
	}
	public String getRows() {
		return rows;
	}
	public void setRows(String rows) {
		this.rows = rows;
	}
	@Override
	public int compareTo(Object o) {
		QuestionBaseOutput another = (QuestionBaseOutput) o;
		String[] newSequence = sequence.split("\\.");
		String[] anotherSequence = another.getSequence().split("\\.");
		// 1.10 --1.2
		if (newSequence.length >= anotherSequence.length) {
			for (int i = 0; i < newSequence.length; i++) {
				String s1 = newSequence[i];
				String s2 = "0";
				if (i < anotherSequence.length) {
					s2 = anotherSequence[i];
				}
				if (s1.equals(s2)) {
					continue;
				} else {
					return Integer.valueOf(s1)-Integer.valueOf(s2);
				}
			}
		} else {
			for (int i = 0; i < anotherSequence.length; i++) {
				String s1 = "0";
				String s2 = anotherSequence[i];
				if (i < newSequence.length) {
					s1 = newSequence[i];
				}
				if (s1.equals(s2)) {
					continue;
				} else {
					return Integer.valueOf(s1)-Integer.valueOf(s2);
				}
			}
		}
		return sequence.compareTo(another.getSequence());
    }
}
